{% extends 'base.html' %}
{% block title %}
    操作记录
{% endblock %}
{% block header_name %}
    操作记录
{% endblock %}
{% block body %}
      <!-- Breadcrumb-->
    <div class="breadcrumb-holder container-fluid">
    <ul class="breadcrumb">
      <li class="breadcrumb-item"><a href="{% url 'index' %}">首页</a></li>
      <li class="breadcrumb-item active">操作记录</li>
    </ul>
    </div>

    <section class="tables">
      <div class="container-fluid">
        <div class="row">
          <div class="col-lg-12">
            <div class="card">
              <div class="page-header">
                <h1>共有{{ count }}条操作记录</h1>
              </div>
              <div class="card-body">
                <div class="table-responsive">
                  {% with request.user.role as role %}
                  <table class="table table-striped table-hover table-bordered ">
                    <thead>
                      <tr>
                        <th>序号</th>
                        <th>时间</th>
                        {% if role == 1 %}
                          <th>操作者</th>
                        {% endif %}
                        <th>内容</th>
                      </tr>
                    </thead>
                    <tbody>
                      {% for log in logs %}
                          <tr>
                          <td>{{ forloop.counter }}</td>
                          <td>{{ log.created_at }}</td>
                            {% if role == 1 %}
                              <td>{{ log.user }}({{ log.user.get_role_display }})</td>
                            {% endif %}
                          <td>{{ log.content }}</td>
                          </tr>
                      {% endfor %}
                    </tbody>
                  </table>
                </div>
                {% endwith %}
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>

    {% include 'pagination.html' %}
{% endblock %}

